from collections import deque

"构建图"
graph = {}
graph["you"] = ["alice", "bob", "claire"]
graph["bob"] = ["anuj", "peggy"]
graph["alice"] = ["peggy"]
graph["claire"] = ["thom", "jonny"]
graph["anuj"] = []
graph["peggy"] = []
graph["thom"] = []
graph["jonny"] = []

def person_is_seller(name):
    "根据名称判断是否是芒果销售商"
    return name[-1]=='m'


def search(name):
    search_queue=deque()
    search_queue+=graph[name]
    searched=[]  #存放已经被检查的人
    while(search_queue):
        person=search_queue.popleft()  #取出第一个人
        if not person in search_queue:
            if person_is_seller(person):
                print(person+"是芒果销售商")
                return True
            else:
                search_queue+=graph[person]
                searched.append(person)
    return False

search("you")